function [ ] = plotAggCostFuncWrapper(ctrS, filestub, optfig)

for t = 1:max(ctrS.output_it.id_period)
    ctrS.period = t;
    filename = [ filestub sprintf('_%02.0f',t) ];

    if ctrS.scenario.costs == "iso"
        [graphPrices, graphYMat] = plotAggCostIso(ctrS);
    elseif ctrS.scenario.costs == "step"
        [graphPrices, graphYMat] = plotAggCostStep(ctrS);
    end

    titlestring = strcat("Aggregate Cost Curve in Period ", string(t));
    f0 = figure;

    set(gca, optfig.labProp{:}, ...
        'Box'         , 'off'             , ...
        'LineWidth'   , optfig.axisweight, ...
        'YScale'      , 'log');
    hold on
    area(graphPrices, graphYMat);%, 'FaceColor','black','EdgeColor','none')
    ylabel("Aggregate Emissions",optfig.textProp{:})
    xlabel("MAC",optfig.textProp{:})
    view([90 -90])

    title(titlestring,optfig.textProp{:},'Interpreter','latex');
    hold off



    fig = gcf;
    fig.PaperPositionMode = 'auto';
    fig.PaperSize = [8 7];
    fig.PaperPosition = [0 0 8 7];

    print(f0,'-dpdf','-painters','-noui','-r600', filename)
end
close all

end

